from functools import partial



# https://www.cnblogs.com/wxys/p/13756552.html

# add, subtract, multiply and divide
# def addone(x):
#     return x+1

# add = partial(addone, 3)
# # 调用add()函数
# print(add())

# def sum_two(x, y):
#     return x+y

# sum_y = partial(sum_two, 5)
# print(sum_y(6))

# def subtract(x, y):
#     return x-y

# subtract_y = partial(subtract, 10)
# # 这里前面固定的10为左边参数x的值
# print(subtract_y(6))
# # 4



"回调函数"
# # 定义一个函数，然后将这个函数的函数名传递给另一个函数做参数，以这个参数命名的函数就是回调函数
# def my_callbcak(args):
#     print(*args)

# def caller(args, func):
#     func(args)

# 这里my_callback就是回调函数
# caller((1,2), my_callbcak) 


# def show(name, age):
#     print("my name is {} and age is {} ". format (name, age))
    
# showP = partial(show, "yangyanxing", 19)
# def test(callback): 
#     print("do some opt...") 
#     callback()
   
# test(showP) 

# # do some opt...
# # my name is yangyanxing and age is 19 





